import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

//路由,每个路由对应一个组件
const routes = [
    {
        path: '/',
        redirect: '/login'
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('../views/Login.vue')
    },
    {
        path: '/frame',
        name: 'Frame',
        component: () => import('../components/Frame.vue'),
        redirect: '/home',
        children: [
            {
                path: '/home',
                name: 'Home',
                component: () => import('../views/Home.vue')
            },
            {
                path: '/personal',
                name: 'Personal',
                component: () => import('../views/Personal.vue')
            },
            {
                path: '/notice',
                name: 'Notice',
                component: () => import('../views/notice/Notice.vue'),
                redirect: '/notice/UnRead',
                children: [
                    {
                        path: '/notice/unRead',
                        name: 'UnRead',
                        component: () => import('../views/notice/UnRead.vue')
                    },
                    {
                        path: '/notice/read',
                        name: 'Read',
                        component: () => import('../views/notice/Read.vue')
                    }
                ]
            },
            // 管理员列表页
            {
                path: '/MusicManage',
                name: 'MusicManage',
                component: ()=> import('../views/MusicManage/MusicManage')
            },
            // 管理员工列表页
            {
                path: '/manage/employees',
                name: 'Employees',
                component: () => import('../views/manage/Employees.vue')
            },
            // 管理角色列表页
            {
                path: '/manage/adminRoles',
                name: 'AdminRoles',
                component: () => import('../views/manage/AdminRoles')
            },
            //角色菜单页
            {
                path: '/manage/rolesMenu',
                name: 'RolesMenu',
                component: () => import('../views/manage/RolesMenu')
            },
            // 文章分类
            {
                path: '/Article/ArticleCategory',
                name: 'ArticleCategory',
                component: () => import('../views/Article/ArticleCategory.vue')
            },
            // 文章评论
            {
                path: '/Article/ArticleComment',
                name: 'ArticleComment',
                component: () => import('../views/Article/ArticleComment.vue')
            },
            // 文章列表
            {
                path: '/Article/ArticleList',
                name: 'ArticleList',
                component: () => import('../views/Article/ArticleList.vue')
            },
            // 文章标签
            {
                path: '/Article/ArticleTag',
                name: 'ArticleTag',
                component: () => import('../views/Article/ArticleTag.vue')
            },
            // 图片管理
            {
                path: '/ImageManage/Imagemanage',
                name: 'Imagemanage',
                component: () => import('../views/ImageManage/Imagemanage.vue')
            },
            // 用户管理
            {
                path: '/UserManage/UserManage',
                name: 'UserManage',
                component: () => import('../views/UserManage/UserManage.vue')
            },
            {
                path: '/manage/admin',
                name: 'admin',
                component: () => import('../views/manage/Admin.vue')
            },
        ]
    }
]

const router = new VueRouter ({
    mode: 'history',
    routes
})

//避免重复点击导航爆错 
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

export default router